interplot¶
Create matplotlib/plotly hybrid plots with a few lines of code.
It combines the best of the matplotlib and the plotly worlds through
a unified, flat API.
All the necessary boilerplate code is contained in this module.
Currently supported:
line plots (scatter)
line fills
histograms
heatmaps
boxplot
linear regression
text annotations
2D subplots
color cycling
Resources¶
Documentation: https://interplot.janjo.ch
Source Code: https://github.com/janjoch/interplot
Licence¶
Demo¶
View on NBViewer:
Try on Binder:
Install¶
pip install interplot
dev installation¶
git clone https://github.com/janjoch/interplotcd interplotpip install -e .
Documentation and API reference¶
interplot
zip iteration helper functions
Example¶
>>> interplot.line([0,4,6,7], [1,2,4,8])
>>> interplot.line(
... x=[0,4,6,7],
... y=[1,2,4,8],
... interactive=False,
... color="red",
... title="matplotlib static figure",
... xlabel="abscissa",
... ylabel="ordinate",
... )
>>> fig = interplot.Plot(
... interactive=True,
... title="Everything Under Control",
... fig_size=(800, 500),
... rows=1,
... cols=2,
... shared_yaxes=True,
... save_fig=True,
... save_format=("html", "png"),
... # ...
... )
... fig.add_hist(np.random.normal(1, 0.5, 1000), row=0, col=0)
... fig.add_boxplot(
... [
... np.random.normal(20, 5, 1000),
... np.random.normal(40, 8, 1000),
... np.random.normal(60, 5, 1000),
... ],
... row=0,
... col=1,
... )
... # ...
... fig.post_process()
... fig.show()
saved figure at Everything-Under-Control.html
saved figure at Everything-Under-Control.png
>>> @interplot.magic_plot
... def plot_lines(samples=100, n=10, label="sigma={0}, mu={1}", fig=None):
... """
... Plot Gaussian noise.
...
... The function must accept the `fig` parameter from the decorator.
... """
... for i in range(1, n+1):
... fig.add_line(
... np.random.normal(i*10,i,samples),
... label=label.format(i, i*10),
... )
>>> plot_lines(samples=200, title="Normally distributed Noise")
>>> plot_lines(
... samples=200, interactive=False, title="Normally distributed Noise")